package com.wc.算法基础课.A第一讲基础算法.前缀和与差分.递增三元组;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/1 15:32
 * @description https://www.acwing.com/problem/content/1238/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N], b = new int[N], c = new int[N];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) b[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) c[i] = sc.nextInt();
        Arrays.sort(a, 1, n + 1);
        Arrays.sort(b, 1, n + 1);
        Arrays.sort(c, 1, n + 1);
        a[n + 1] = N;
        b[n + 1] = N;
        long res = 0;
        // 枚举b当中的数，求a中小于b的个数，c中大于b的个数
        for (int i = 1; i <= n; i++) {
            int cnt1 = binary1(b[i]);
            int cnt2 = binary2(b[i]);
            res += (long) cnt1 * (n - cnt2 + 1);
        }
        out.println(res);
        out.flush();
    }

    static int binary1(int k) {
        int l = 1, r = n;
        int ans = 0;
        while (l <= r) {
            int mid = l + r >> 1;
            if (a[mid] < k) {
                ans = mid;
                l = mid + 1;
            } else r = mid - 1;
        }

        return ans;
    }

    static int binary2(int k) {
        int l = 1, r = n;
        int ans = n + 1;
        while (l <= r) {
            int mid = l + r >> 1;
            if (c[mid] > k) {
                ans = mid;
                r = mid - 1;
            } else l = mid + 1;
        }

        return ans;
    }
}


class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}